package cn.smartaccount.demo.controller;

import cn.smartaccount.demo.common.util.HttpClientUtil;
import cn.smartaccount.demo.dto.Response;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;

/**
 * @author anhaimeng
 * @date 2023-11-08 17:57
 */
@RestController
@RequestMapping(value = "test")
public class TestController {



    @GetMapping("/login")
    public Response login(@RequestParam String code) {
//        1.参数校验
//        2.调用微信小程序接口
        String appID = "wx4b2c12ffe7da7c99";
        String appSecret = "256aea039afd6233072539958acf53b2";
        String url2 = "https://v0.yiketianqi.com/api?unescape=1&version=v9&appid=61641876&appsecret=4Gj2hvos&city=%s";
        //city=上海
        url2 = String.format(url2, code);
        String result2 = HttpClientUtil.postFormBody(url2, null);
        System.out.println(JSONObject.parse(result2));
//        3.用户注册


//        4.生成token
//        5.返回token
        return Response.success(code);
    }


}